package com.jiyinit.web.core.business.dao;

import com.jiyinit.core.framework.dao.mybatis.base.MybatisDaoContext;
import com.jiyinit.web.core.business.entity.TabCoreFunEntity;
import com.jiyinit.web.core.business.entity.TabLoginInfoEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

import java.util.HashMap;

/**
 * <p></p>
 * <p/>
 * <PRE>
 * <BR>	修改记录
 * <BR>-----------------------------------------------
 * <BR>	修改日期			修改人			修改内容
 * </PRE>
 *
 * @author zhaolaiwei
 * @version 1.0
 * @date 2017/4/11 17:51
 * @since 1.0
 */
@Repository("login.tabLoginUserDao")
public class TabLoginUserDao {

    /**
     * 日志对象
     */
    private static Logger logger = LoggerFactory.getLogger(TabLoginUserDao.class);

    private String SQLID = "login.tabLoginUserDao.";

    @Autowired
    @Qualifier("core.MybatisDaoContext")
    private MybatisDaoContext mybatisDaoContext;


   public TabLoginInfoEntity getLoginInfoByUserId(Integer userId){
       return mybatisDaoContext.findOne(SQLID+"getLoginInfoByUserId" ,TabLoginInfoEntity.class,userId);
   }

    public int logout(Integer userId){
        HashMap<String,Object> params = new HashMap();
        params.put("userId",userId);
        return mybatisDaoContext.update(SQLID+"logout",params);
    }

    public int insert(TabLoginInfoEntity info){
        return mybatisDaoContext.save(SQLID + "insertSelective",info);
    }
    public int update(TabLoginInfoEntity info){
        return mybatisDaoContext.update(SQLID+"updateByPrimaryKeySelective",info);
    }

}
